package o;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.Build.VERSION;
import android.os.CancellationSignal;
import android.os.Handler;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import androidx.core.content.res.FontResourcesParserCompat;
import androidx.core.content.res.FontResourcesParserCompat.c;
import androidx.core.content.res.FontResourcesParserCompat.e;
import androidx.core.provider.FontsContractCompat;
import androidx.core.provider.FontsContractCompat.b;

public class ft {
    private static final dx<String, Typeface> ˊ = new dx(16);
    private static final gb ˏ;

    static {
        if (VERSION.SDK_INT >= 28) {
            ˏ = new fy();
        } else if (VERSION.SDK_INT >= 26) {
            ˏ = new fz();
        } else if (VERSION.SDK_INT >= 24 && ga.ˏ()) {
            ˏ = new ga();
        } else if (VERSION.SDK_INT >= 21) {
            ˏ = new gc();
        } else {
            ˏ = new gb();
        }
    }

    @Nullable
    @RestrictTo({d.ॱ})
    public static Typeface ˏ(@NonNull Resources resources, int i, int i2) {
        return (Typeface) ˊ.ˏ(ˋ(resources, i, i2));
    }

    private static String ˋ(Resources resources, int i, int i2) {
        return resources.getResourcePackageName(i) + "-" + i + "-" + i2;
    }

    @Nullable
    @RestrictTo({d.ॱ})
    public static Typeface ˏ(@NonNull Context context, @NonNull c cVar, @NonNull Resources resources, int i, int i2, @Nullable fv.d dVar, @Nullable Handler handler, boolean z) {
        Typeface ˏ;
        boolean z2 = true;
        if (cVar instanceof FontResourcesParserCompat.d) {
            FontResourcesParserCompat.d dVar2 = (FontResourcesParserCompat.d) cVar;
            if (z) {
                if (dVar2.ˋ() != 0) {
                    z2 = false;
                }
            } else if (dVar != null) {
                z2 = false;
            }
            ˏ = FontsContractCompat.ˏ(context, dVar2.ˏ(), dVar, handler, z2, z ? dVar2.ˊ() : -1, i2);
        } else {
            ˏ = ˏ.ॱ(context, (e) cVar, resources, i2);
            if (dVar != null) {
                if (ˏ != null) {
                    dVar.ˋ(ˏ, handler);
                } else {
                    dVar.ˊ(-3, handler);
                }
            }
        }
        if (ˏ != null) {
            ˊ.ˋ(ˋ(resources, i, i2), ˏ);
        }
        return ˏ;
    }

    @Nullable
    @RestrictTo({d.ॱ})
    public static Typeface ˏ(@NonNull Context context, @NonNull Resources resources, int i, String str, int i2) {
        Typeface ॱ = ˏ.ॱ(context, resources, i, str, i2);
        if (ॱ != null) {
            ˊ.ˋ(ˋ(resources, i, i2), ॱ);
        }
        return ॱ;
    }

    @Nullable
    @RestrictTo({d.ॱ})
    public static Typeface ˎ(@NonNull Context context, @Nullable CancellationSignal cancellationSignal, @NonNull b[] bVarArr, int i) {
        return ˏ.ˋ(context, cancellationSignal, bVarArr, i);
    }
}
